<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绝对定位的参考点_祖先元素</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box1{
            width: 400px;
            height: 400px;
            border: 5px solid red;
            margin: 100px auto;
            position: relative;
        }
        .box2{
            width: 200px;
            height: 200px;
            border: 5px solid green;
            padding: 50px;
            position: absolute;
            left: 50px;
            top: 50px;
        }
        .box3{
            width: 200px;
            height: 200px;
            border: 5px solid blue;
            /* position: absolute;
            left: 50px;
            top: 50px; */
        }
        p{
            width: 50px;
            height: 50px;
            background: gold;
            position: absolute;
            top: 50px;
            left: 50px;
        }
    </style>
</head>
<body>
    <div class="box1">               <!-- 相对定位 -->
        <div class="box2">           <!-- 绝对定位 -->
            <div class="box3">       <!-- 没有定位 -->
                <p></p>              <!-- 目标元素，绝对定位，参考的是 box2 -->
            </div>
        </div>
    </div>
</body>
</html>